
var express = require('express');//express核心
var path = require('path');//path模块
var cookieParser = require('cookie-parser');//cookie转换模块 可以用来设置cookie
var logger = require('morgan');//摩根 日志模块
//路由
var indexRouter = require('./routes/index');
var usersRouter = require('./routes/users');
let stuRouter = require('./routes/stu')

var app = express();//创建服务

// 设置视图引擎
app.set('views', path.join(__dirname, 'views'));
app.set('view engine', 'ejs');

app.use(logger('dev')); //输出开发模式的日志
app.use(express.json());//传输的是json格式
app.use(express.urlencoded({ extended: false }));//处理post请求的数据
app.use(cookieParser());//启用了cookie插件
//静态资源托管
app.use(express.static(path.join(__dirname, 'public')));
app.use(express.static(path.resolve("assets")));

//匹配路由
app.use('/', indexRouter);
app.use('/users', usersRouter);
app.use('/test',stuRouter)



module.exports = app;
